package org.android.brasil.projetos.oktoberfest2011.view;

import org.android.brasil.projetos.oktoberfest2011.R;
import org.android.brasil.projetos.oktoberfest2011.utils.AnalyticsUtils;
import org.android.brasil.projetos.oktoberfest2011.utils.Constantes;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class AgendaTabView extends TabActivity {

	private AnalyticsUtils mGa;
	
	private TabHost tabHost;
	private static String[] setores = new String[] { Constantes.SETOR1,
			Constantes.SETOR2, Constantes.SETOR3, Constantes.SETOR4, };

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		this.mGa = AnalyticsUtils.getInstance(this);
		
		setContentView(R.layout.agenda_tab_view);

		bindScreenFields();
		populateFields();

		this.mGa.trackScreen(getString(R.string.agenda));
	}

	private void bindScreenFields() {
		tabHost = getTabHost();
	}

	private void populateFields() {

		Integer[] draw = new Integer[] { R.drawable.setor1, R.drawable.setor2,
				R.drawable.setor3, R.drawable.biergarten };
		int i = 0;
		for (String set : setores) {
			TabHost.TabSpec spec;
			Intent intent = new Intent().setClass(this, AgendaView.class);
			if (getIntent().getExtras() != null) {
				intent.putExtras(getIntent().getExtras());
			}
			intent.putExtra("SETOR", set);
			spec = tabHost.newTabSpec(set)
					.setIndicator(set, getResources().getDrawable(draw[i]))
					.setContent(intent);
			i = i + 1;
			tabHost.addTab(spec);
		}
	}
	
	protected void onDestroy() {
		super.onDestroy();
	}
}
